<div class="widgets">

  <div class="row">
    <div class="col-xs-12">
      <ba-card baCardClass="with-scroll">
        <div class="section">
          <form (ngSubmit)="search()" class="form-horizontal">
            <div class="form-group row">

              <div class="col-sm-5">
                <label for="idcard" class="col-sm-5 control-label">身&nbsp;&nbsp;份&nbsp;&nbsp;证</label>
                <div class="col-sm-7">
                  <input [(ngModel)]="searchForm.idcard" name="idcard" type="text" class="form-control">
                </div>
              </div>

              <div class="col-sm-5">
                <label for="name" class="col-sm-5 control-label">姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名</label>
                <div class="col-sm-7">
                  <input [(ngModel)]="searchForm.name" name="name" type="text" class="form-control">
                </div>
              </div>

            </div>

            <div class="form-group row">

              <div class="col-sm-5">
                <label for="type" class="col-sm-5 control-label">证书类型</label>
                <div class="col-sm-7">
                  <select [(ngModel)]="searchForm.type" name="type" type="text" class="form-control">
                    <option value="" selected>全部</option>
                    <option value="质量员">质量员</option>
                    <option value="施工员">施工员</option>
                    <option value="安全员">安全员</option>
                    <option value="标准员">标准员</option>
                    <option value="材料员">材料员</option>
                    <option value="机械员">机械员</option>
                    <option value="劳务员">劳务员</option>
                    <option value="资料员">资料员</option>
                  </select>
                </div>
              </div>

              <div class="col-sm-5">
                <label for="verified" class="col-sm-5 control-label">申请状态</label>
                <div class="col-sm-7">
                  <select [(ngModel)]="searchForm.verified" name="verified" type="text" class="form-control">
                    <option value="待审核">待审核</option>
                    <option value="通过">通过</option>
                    <option value="未通过">未通过</option>
                    <option value="">全部</option>
                  </select>
                </div>
              </div>
            </div>
            <div class="form-group row">
              <div class="col-sm-5">
                <label for="available" class="col-sm-5 control-label">证书状态</label>
                <div class="col-sm-7">
                  <select [(ngModel)]="searchForm.available" name="available" type="text" class="form-control">
                    <option value="有效">未过期</option>
                    <option value="无效">已过期</option>
                    <option value="">全部</option>
                  </select>
                </div>
              </div>
              <div class="col-sm-5">
                <label id="publishTimeLabel" class="col-sm-5 control-label" for="startdate">时&nbsp;&nbsp;间&nbsp;&nbsp;段</label>

                <div class="col-sm-7" id="publishTimeCol">
                  <date-range-picker (onSelected)="updateDateRange($event)"></date-range-picker>
                </div>
              </div>
              <div class="col-sm-2">
                <button type="submit" class="btn btn-primary pull-left"><i class="fa fa-search" aria-hidden="true"></i>查询
                </button>
              </div>
            </div>
          </form>
        </div>
        <div class="section btn-section btn-toolbar">
          <a role="button" class="btn btn-primary btn-review" [ngClass]="{'disabled': disableReviewBtn}"
             (click)="review()">查看</a>
          <a role="button" class="btn btn-success btn-review" [ngClass]="{'disabled': disablePassBtn}"
             (click)="showPassModal()">通过</a>
          <a role="button" class="btn btn-danger btn-reject" [ngClass]="{'disabled': disableRejectBtn}"
             (click)="showRejectModal()">驳回</a>
          <a role="button" class="btn btn-danger btn-review" [ngClass]="{'disabled': disableActBtn}"
             (click)="showActivateModal()">激活</a>
          <a role="button" class="btn btn-danger btn-reject" [ngClass]="{'disabled': disableDeleteBtn}"
             (click)="showDeleteModal()">删除</a>
         <!-- <a role="button" class="btn btn-info btn-download" [ngClass]="{'disabled': disableDownloadBtn}"
             href="{{downloadUrl}}" download target="_blank">下载信息(点选)</a>
          <a role="button" class="btn btn-info btn-download" [ngClass]="{'disabled': disableDownloadTimeBtn}"
             (click)="showTimeModal()">下载信息(时间)</a>-->
          <span *ngIf="errorShow">请重新登录</span>
          <!--<a role="button" class="btn btn-info btn-download" [ngClass]="{'disabled': disableDownloadBtn}"-->
             <!--href="{{downloadUrl}}" download target="_blank">下载申请</a>-->
        </div>
        <div class="section">
          <data-tables [searchParams]="searchForm" [config]="dataTablesConfig"
                       (onSelect)="tableRowSelect($event)"  (onError)="handleError($event)"></data-tables>
        </div>
      </ba-card>
    </div>
  </div>
</div>

<div bsModal #apprPassModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="entRegApprModalLabel"
     aria-hidden="true" (onHide)="onHideModal()">
  <div class="modal-dialog modal-lg">
    <div class="modal-content" style="color: #000;">
      <div class="modal-header">
        <button class="close" (click)="apprPassClose()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">审核通过</h4>
      </div>

      <div class="modal-body">
        <div class="auth-block">
          <!--<div class="form-group row">-->
            <!--<label class="col-sm-2 form-control-label pull-left">延期年数</label>-->
            <!--<div class="col-sm-2">-->
              <!--<select type="text" class="form-control" #year>-->
                <!--<option value=3 selected>3</option>-->
                <!--<option value=6>6</option>-->
                <!--<option value=9>9</option>-->
                <!--<option value=12>12</option>-->
                <!--<option value=15>15</option>-->
                <!--<option value=18>18</option>-->
              <!--</select>-->
            <!--</div>-->
          <!--</div>-->
          <div class="form-group row">
            <label for="textarea01" class="col-sm-2">审核意见</label>
            <div class="col-sm-10">
              <textarea class="form-control" #passComment></textarea>
            </div>
            <span *ngIf="_errorMsg">{{_errorMsg}}</span>
          </div>
        </div>
      </div>

      <div class="modal-footer">
        <button class="btn btn-primary confirm-btn" (click)="pass(passComment.value)">提交</button>
        <button class="btn btn-default" (click)="apprPassClose()">取消</button>
      </div>
    </div>
  </div>
</div>


<div bsModal #apprRejectModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="entRegApprModalLabel"
     aria-hidden="true" (onHide)="onHideModal()">
  <div class="modal-dialog modal-lg">
    <div class="modal-content" style="color: #000;">
      <div class="modal-header">
        <button class="close" (click)="apprRejectClose()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">审核驳回</h4>
      </div>

      <div class="modal-body">
        <div class="auth-block">
          <div class="form-group">
            <label for="textarea01">审核意见</label>
            <textarea class="form-control" #rejcetComment></textarea>
            <span *ngIf="_errorMsg">{{_errorMsg}}</span>
          </div>
        </div>
      </div>

      <div class="modal-footer">
        <button class="btn btn-primary confirm-btn" (click)="reject(rejcetComment.value)">提交</button>
        <button class="btn btn-default" (click)="apprRejectClose()">取消</button>
      </div>
    </div>
  </div>
</div>

<div bsModal #apprActivateModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="entRegApprModalLabel"
     aria-hidden="true" (onHide)="onHideModal()">
  <div class="modal-dialog modal-lg">
    <div class="modal-content" style="color: #000;">
      <div class="modal-header">
        <button class="close" (click)="apprActivateClose()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">激活</h4>
      </div>

      <div class="modal-body">
        <div class="auth-block form-horizontal">
          <div class="form-group row">
            <label class="col-sm-2 form-control-label">延期年数</label>
            <div class="col-sm-10">
              <select type="text" class="form-control" #year>
                <option value=3 selected>3</option>
                <option value=6>6</option>
                <option value=9>9</option>
                <option value=12>12</option>
                <option value=15>15</option>
              </select>
            </div>
          </div>
          <div class="form-group row">
            <label for="textarea01" class="col-sm-2 form-control-label">审核意见</label>
            <div class="col-sm-10">
              <textarea class="form-control" #rejcetComment></textarea>
            </div>
            <span *ngIf="_errorMsg">{{_errorMsg}}</span>
          </div>
        </div>
      </div>

      <div class="modal-footer">
        <button class="btn btn-primary confirm-btn" (click)="activate(year.value, passComment.value)">提交</button>
        <button class="btn btn-default" (click)="apprActivateClose()">取消</button>
      </div>
    </div>
  </div>
</div>

<div bsModal #apprReviewModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="entRegApprModalLabel"
     aria-hidden="true" (onHide)="onHideModal()">
  <div class="modal-dialog modal-lg">
    <div class="modal-content" style="color: #000;">
      <div class="modal-header">
        <button class="close" (click)="apprReviewModal.hide()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">详情</h4>
      </div>

      <div class="modal-body">
        <div class="auth-block">
          <form class="form-horizontal" *ngIf="_selectdAppr">
            <div class="form-group row"><label class="col-sm-2 form-control-label">证书类型</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.type}}">
              </div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">证书编号</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.serialno}}">
              </div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">姓名</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.name}}">
              </div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">身份证号码</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.idcard}}">
              </div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">性别</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.sex}}">
              </div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">出生年月</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.birthday}}">
              </div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">公司</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.companyname}}"></div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">签发日期</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.issuedate}}"></div>
            </div>
            <div class="form-group row"><label class="col-sm-2 form-control-label">新有效期</label>
              <div class="col-sm-10"><input type="text" class="form-control" readonly
                                            value="{{_selectdAppr.certificate.availabletime}}"></div>
            </div>
            <div class="form-group row">
              <label class="col-sm-2 form-control-label">培训记录</label>
              <div class="col-sm-10" *ngIf="_selectdAppr.files && _selectdAppr.files.incidentDoc">
                <a href="{{_selectdAppr.files.incidentDoc.path}}" download>{{_selectdAppr.files.incidentDoc.originalfilename}}</a>
              </div>
              <div class="col-sm-10" *ngIf="_selectdAppr.files && _selectdAppr.files.incidentDoc == null || _selectdAppr.files == null">
                <input type="text" class="form-control"
                       value="无下载文件" readonly>
              </div>
            </div>
            <div class="form-group row">
              <label class="col-sm-2 form-control-label">事故相关文件</label>
              <div class="col-sm-10" *ngIf="_selectdAppr.files && _selectdAppr.files.trainRecord">
                <a href="{{_selectdAppr.files.trainRecord.path}}" download>{{_selectdAppr.files.trainRecord.originalfilename}}</a>
              </div>
              <div class="col-sm-10" *ngIf="_selectdAppr.files && _selectdAppr.files.trainRecord == null || _selectdAppr.files == null">
                <input type="text" class="form-control"
                       value="无下载文件" readonly>
              </div>
            </div>
            <!--<div class="form-group row"><label class="col-sm-2 form-control-label">原有效期</label>-->
              <!--<div class="col-sm-10"><input type="text" class="form-control" readonly-->
                                            <!--value="{{_selectdAppr.certificate.oldavailabletime}}"></div>-->
            <!--</div>-->
            <!--<div class="form-group row" *ngIf="_selectdAppr.files[0]">-->
              <!--<label class="col-sm-2 form-control-label">文件下载</label>-->
              <!--<div class="col-sm-10">-->
                <!--<a href="{{file.path}}" download *ngFor="let file of _selectdAppr.files">{{file.originalfilename}}&nbsp;&nbsp;</a>-->
              <!--</div>-->
            <!--</div>-->
            <div class="form-group row" *ngIf="_selectdAppr.certificate.verified != '待审核'"><label class="col-sm-2 form-control-label">审核意见</label>
              <div class="col-sm-10"><input type="text" class="form-control"
                                            [value]="_selectdAppr.certificate.verifydescription" readonly>
              </div>
            </div>
            <div class="form-group row" *ngIf="_selectdAppr.certificate.verified != '待审核'"><label class="col-sm-2 form-control-label">审批时间</label>
              <div class="col-sm-10"><input type="text" class="form-control"
                                            [value]="_selectdAppr.certificate.verifytime" readonly>
              </div>
            </div>
            <div class="form-group row" *ngIf="_selectdAppr.certificate.verified === '待审核'">
              <label for="textarea01" class="col-sm-2 form-control-label">审核意见</label>
              <div class="col-sm-10">
                <textarea class="form-control" #CheckComment></textarea>
                <a role="button" class="btn btn-success btn-pass check"(click)="pass(CheckComment.value)">通过</a>
                <a role="button" class="btn btn-danger btn-reject check"(click)="reject(CheckComment.value)">驳回</a>
              </div>
            </div>
          </form>
        </div>
      </div>

      <div class="modal-footer">
        <button class="btn btn-default" (click)="apprReviewModal.hide()">关闭</button>
      </div>
    </div>
  </div>
</div>

<div bsModal #apprDeleteModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="entRegApprModalLabel"
     aria-hidden="true" (onHide)="onHideModal()">
  <div class="modal-dialog modal-lg">
    <div class="modal-content" style="color: #000;">
      <div class="modal-header">
        <button class="close" (click)="apprDeleteClose()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">删除</h4>
      </div>

      <div class="modal-body">
        确定要删除吗
      </div>

      <div class="modal-footer">
        <button class="btn btn-primary confirm-btn" (click)="delete()">删除</button>
        <button class="btn btn-default" (click)="apprDeleteClose()">取消</button>
      </div>
    </div>
  </div>
</div>

<div bsModal #apprTimeModal="bs-modal" class="modal fade" tabindex="-1" role="dialog"
     aria-labelledby="entRegApprModalLabel"
     aria-hidden="true" (onHide)="onHideModal()">
  <div class="modal-dialog modal-lg">
    <div class="modal-content" style="color: #000;">
      <div class="modal-header">
        <button class="close" (click)="apprTimeClose()" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title">按时间段下载</h4>
      </div>

      <div class="modal-body">
        <div class="auth-block">
          <div class="form-group">
            <label class="control-label" for="startdate">时间段</label>

            <div >
              <date-range-picker (onSelected)="getStage($event)"></date-range-picker>
            </div>
          </div>
        </div>
      </div>

      <div class="modal-footer">
        <a class="btn btn-primary confirm-btn" href="{{downloadUrlByStage}}" download target="_blank" (click)="apprTimeClose()">提交</a>
        <button class="btn btn-default" (click)="apprTimeClose()">取消</button>
      </div>
    </div>
  </div>
</div>
